package com.dp.mallchat.common.user.service.impl;

import com.dp.mallchat.common.common.constant.MQConstant;
import com.dp.mallchat.common.common.domain.dto.PushMessageDTO;
import com.dp.mallchat.common.user.domain.ws.resp.WSBaseResp;
import com.dp.mallchat.transaction.service.MQProducter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author: dupeng
 * @CreateTime: 2024-07-05  18:43
 * @Description: 向用户推送消息收口
 */
@Service
@Slf4j
public class PushService {

    @Autowired
    private MQProducter mqProducter;


    public void sendPushMsg(WSBaseResp<?> message) {
        mqProducter.sendMessage(MQConstant.PUSH_TOPIC, new PushMessageDTO(message));
    }

    public void sendPushMsg(WSBaseResp<?> message, List<Long> uidList) {
        mqProducter.sendMessage(MQConstant.PUSH_TOPIC, new PushMessageDTO(uidList, message));
    }

    public void sendPushMsg(WSBaseResp<?> msg, Long uid) {
        mqProducter.sendMessage(MQConstant.PUSH_TOPIC, new PushMessageDTO(uid, msg));
    }
}
